﻿import QtQuick 2.12
import QtQuick.Window 2.12
import "../components"

Window {

    id: root
    title: "数据统计"
    modality: Qt.WindowModal
    flags: Qt.Window | Qt.WindowTitleHint |Qt.WindowSystemMenuHint | Qt.WindowCloseButtonHint

    height: 500*dp
    width: 430*dp

    signal accept()

    onVisibleChanged: {
        edit_equName.       setText(filter["EquName"])
        edit_ip.            setText(filter["Ip"])
        edit_runtime_1.     setText(filter["RunningTimeBegin"])
        edit_runtime_2.     setText(filter["RunningTimeEnd"])
        edit_detecttime_1.  setText(filter["TestTimeBegin"])
        edit_detecttime_2.  setText(filter["TestTimeEnd"])
        edit_expnum_1.      setText(filter["ExpNumBegin"])
        edit_expnum_2.      setText(filter["ExpNumEnd"])
        edit_detectnum_1.   setText(filter["TestSampleNumBegin"])
        edit_detectnum_2.   setText(filter["TestSampleNumEnd"])
    }

    Column{
        x: 40*dp
        y: 40*dp
        spacing: 20*dp
        LineEditor{
            id: edit_equName
            title: " 设  备  名  称"
            prompt: "全部"
            textWidth: 110*dp
            editWidth: 240*dp
            Keys.onTabPressed: {
                focus = false
                edit_ip.focus = true
            }
        }LineEditor{
            id: edit_ip
            title: " IP / 串 口 号"
            prompt: "全部"
            textWidth: 110*dp
            editWidth: 240*dp
            Keys.onTabPressed: {
                focus = false
                edit_runtime_1.focus = true
            }
        }Row{
            LineEditor{
                id:  edit_runtime_1
                title: "设备运行时长"
                editWidth: 110*dp
                textWidth: 110*dp
                Keys.onTabPressed: {
                    focus = false
                    edit_runtime_2.focus = true
                }
            }LineEditor{
                id: edit_runtime_2
                title: " —"
                textWidth: 20*dp
                editWidth: 110*dp
                Keys.onTabPressed: {
                    focus = false
                    edit_detecttime_1.focus = true
                }
            }
        }Row{
            LineEditor{
                id:  edit_detecttime_1
                title: " 检  测  时  长"
                editWidth: 110*dp
                textWidth: 110*dp
                Keys.onTabPressed: {
                    focus = false
                    edit_detecttime_2.focus = true
                }
            }LineEditor{
                id: edit_detecttime_2
                title: " —"
                textWidth: 20*dp
                editWidth: 110*dp
                Keys.onTabPressed: {
                    focus = false
                    edit_expnum_1.focus = true
                }
            }
        }Row{
            LineEditor{
                id:  edit_expnum_1
                title: " 实  验  次  数"
                editWidth: 110*dp
                textWidth: 110*dp
                Keys.onTabPressed: {
                    focus = false
                    edit_expnum_2.focus = true
                }
            }LineEditor{
                id: edit_expnum_2
                title: " —"
                textWidth: 20*dp
                editWidth: 110*dp
                Keys.onTabPressed: {
                    focus = false
                    edit_detectnum_1.focus = true
                }
            }
        }Row{
            LineEditor{
                id:  edit_detectnum_1
                title: "总检测样本数"
                editWidth: 110*dp
                textWidth: 110*dp
                Keys.onTabPressed: {
                    focus = false
                    edit_detectnum_2.focus = true
                }
            }LineEditor{
                id: edit_detectnum_2
                title: " —"
                textWidth: 20*dp
                editWidth: 110*dp
                Keys.onTabPressed: {
                    focus = false
                    edit_equName.focus = true
                }
            }
        }
    }
    Item{
        y: root.height - 90*dp
        width: root.width
        PushButton{
            title: "取消"
            defaultMode2: true
            x: root.width / 2 - 10*dp - 120*dp
            onReleased: {
                root.close()
            }
        }PushButton{
            title: "确定"
            x: root.width / 2 + 10*dp
            defaultMode1: true
            onReleased: {
                filter["EquName"] = edit_equName.      getText()
                filter["Ip"] = edit_ip.           getText()
                filter["RunningTimeBegin"] = edit_runtime_1.    getText()
                filter["RunningTimeEnd"] = edit_runtime_2.    getText()
                filter["TestTimeBegin"] = edit_detecttime_1. getText()
                filter["TestTimeEnd"] = edit_detecttime_2. getText()
                filter["ExpNumBegin"] = edit_expnum_1.     getText()
                filter["ExpNumEnd"] = edit_expnum_2.     getText()
                filter["TestSampleNumBegin"] = edit_detectnum_1.  getText()
                filter["TestSampleNumEnd"] = edit_detectnum_2.  getText()
                root.accept()
                root.close()
            }
        }PushButton{
            title: "重置"
            text_color: "#1677FF"
            height: 20*dp
            width: 40*dp
            x: root.width / 2 + 10*dp + 130*dp;   y: 10*dp
            onReleased: {
                edit_equName.       setText("")
                edit_ip.            setText("")
                edit_runtime_1.     setText(0)
                edit_runtime_2.     setText(100000)
                edit_detecttime_1.  setText(0)
                edit_detecttime_2.  setText(100000)
                edit_expnum_1.      setText(0)
                edit_expnum_2.      setText(100000)
                edit_detectnum_1.   setText(0)
                edit_detectnum_2.   setText(100000)
            }
        }
    }


}
